package siga.visao_financeiro;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import siga.banco.conexao;
import siga.visao.index;
import siga.visao.verErros;

public class cadPlanoPagVer extends javax.swing.JInternalFrame {
    public boolean novo = true;
    public cadPlanoPagVer() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpCBPrincipal = new javax.swing.JPanel();
        barraFerramentaFonecedor = new javax.swing.JToolBar();
        btNovo = new javax.swing.JButton();
        btAlterar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btSalvar = new javax.swing.JButton();
        btRemover = new javax.swing.JButton();
        btSair = new javax.swing.JButton();
        jpCadastro = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtfCodigo = new javax.swing.JTextField();
        jtfDescricao = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtfData = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfNrParc = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfJrMes = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfJrDia = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtfDesconto = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfValor = new javax.swing.JFormattedTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtfObsBoleto = new javax.swing.JEditorPane();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtfObsFin = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jpTabela = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtBanco = new javax.swing.JTable();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Cadastro do Plano de Pagamento Acadêmico");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/plano_pag_16x16.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameActivated(evt);
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        barraFerramentaFonecedor.setFloatable(false);
        barraFerramentaFonecedor.setRollover(true);

        btNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/novo_32x32.png"))); // NOI18N
        btNovo.setMnemonic('N');
        btNovo.setText("Novo");
        btNovo.setToolTipText("Inseri um Novo Cadastro");
        btNovo.setFocusable(false);
        btNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNovo.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovoActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btNovo);

        btAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/editar_32x32.png"))); // NOI18N
        btAlterar.setMnemonic('A');
        btAlterar.setText("Alterar");
        btAlterar.setToolTipText("Alterar um  Cadastro");
        btAlterar.setEnabled(false);
        btAlterar.setFocusable(false);
        btAlterar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btAlterar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlterarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btAlterar);

        btCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        btCancelar.setMnemonic('C');
        btCancelar.setText("Cancelar");
        btCancelar.setToolTipText("Cancelar um Cadastro");
        btCancelar.setFocusable(false);
        btCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btCancelar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btCancelar);

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        btSalvar.setMnemonic('S');
        btSalvar.setText("Salvar");
        btSalvar.setToolTipText("Salvar um Cadastro");
        btSalvar.setEnabled(false);
        btSalvar.setFocusable(false);
        btSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSalvar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSalvar);

        btRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_32x32.png"))); // NOI18N
        btRemover.setMnemonic('R');
        btRemover.setText("Remover");
        btRemover.setToolTipText("Remove um Cadastro");
        btRemover.setEnabled(false);
        btRemover.setFocusable(false);
        btRemover.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btRemover.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRemoverActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btRemover);

        btSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/sair_32x32.png"))); // NOI18N
        btSair.setMnemonic('S');
        btSair.setText("Sair");
        btSair.setToolTipText("Sair da Janela");
        btSair.setFocusable(false);
        btSair.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSair.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSairActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSair);

        jLabel1.setText("Código:");

        jLabel2.setText("Plano de Pagamento:");

        jtfCodigo.setEnabled(false);

        jtfDescricao.setEnabled(false);

        jLabel3.setText("Data de Início do Boleto:");

        try {
            jtfData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfData.setEnabled(false);

        jLabel4.setText("Número de Parcelas:");

        jtfNrParc.setEnabled(false);

        jLabel5.setText("Juro Mês:");

        jtfJrMes.setEditable(false);
        jtfJrMes.setText("2");

        jLabel6.setText("Juro Dia:");

        jtfJrDia.setEditable(false);
        jtfJrDia.setText("1");

        jLabel7.setText("Desconto:");

        jtfDesconto.setEditable(false);
        jtfDesconto.setText("10");

        jLabel8.setText("Valor do Boleto:");

        jtfValor.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jtfValor.setEnabled(false);

        jLabel9.setText("R$");

        jLabel10.setText("Observações do Boleto:");

        jtfObsBoleto.setEditable(false);
        jtfObsBoleto.setText("- Desconto de 10% para pagamentos até a data do Vencimento."); // NOI18N
        jScrollPane2.setViewportView(jtfObsBoleto);

        jLabel11.setText("Observações para o Setor Financeiro:");

        jtfObsFin.setColumns(20);
        jtfObsFin.setRows(5);
        jtfObsFin.setEnabled(false);
        jScrollPane3.setViewportView(jtfObsFin);

        jLabel12.setText("%");

        jLabel13.setText("%");

        jLabel14.setText("%");

        javax.swing.GroupLayout jpCadastroLayout = new javax.swing.GroupLayout(jpCadastro);
        jpCadastro.setLayout(jpCadastroLayout);
        jpCadastroLayout.setHorizontalGroup(
            jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCadastroLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jpCadastroLayout.createSequentialGroup()
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtfCodigo, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jtfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 688, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jpCadastroLayout.createSequentialGroup()
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtfData, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfNrParc)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(jpCadastroLayout.createSequentialGroup()
                                .addComponent(jtfJrMes, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel14)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addGroup(jpCadastroLayout.createSequentialGroup()
                                .addComponent(jtfJrDia, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addGroup(jpCadastroLayout.createSequentialGroup()
                                .addComponent(jtfDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel12)))
                        .addGap(12, 12, 12)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfValor)
                            .addComponent(jLabel8)))
                    .addGroup(jpCadastroLayout.createSequentialGroup()
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 409, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(54, 54, 54))
        );
        jpCadastroLayout.setVerticalGroup(
            jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCadastroLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(2, 2, 2)
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpCadastroLayout.createSequentialGroup()
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfNrParc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfJrMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfJrDia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)))
                    .addGroup(jpCadastroLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpCadastroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane3, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
                .addContainerGap())
        );

        jtBanco.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Plano de  Pagamento", "Nr Parc", "Data", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtBanco.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtBancoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jtBanco);
        jtBanco.getColumnModel().getColumn(0).setPreferredWidth(60);
        jtBanco.getColumnModel().getColumn(0).setMaxWidth(60);
        jtBanco.getColumnModel().getColumn(2).setPreferredWidth(50);
        jtBanco.getColumnModel().getColumn(2).setMaxWidth(50);
        jtBanco.getColumnModel().getColumn(3).setPreferredWidth(80);
        jtBanco.getColumnModel().getColumn(3).setMaxWidth(80);
        jtBanco.getColumnModel().getColumn(4).setPreferredWidth(60);
        jtBanco.getColumnModel().getColumn(4).setMaxWidth(60);

        javax.swing.GroupLayout jpTabelaLayout = new javax.swing.GroupLayout(jpTabela);
        jpTabela.setLayout(jpTabelaLayout);
        jpTabelaLayout.setHorizontalGroup(
            jpTabelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE)
        );
        jpTabelaLayout.setVerticalGroup(
            jpTabelaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jpCBPrincipalLayout = new javax.swing.GroupLayout(jpCBPrincipal);
        jpCBPrincipal.setLayout(jpCBPrincipalLayout);
        jpCBPrincipalLayout.setHorizontalGroup(
            jpCBPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE)
            .addComponent(jpCadastro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jpTabela, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpCBPrincipalLayout.setVerticalGroup(
            jpCBPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCBPrincipalLayout.createSequentialGroup()
                .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpTabela, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCBPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCBPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovoActionPerformed
        novo=false;
        btSalvar.setEnabled(true);
        btAlterar.setEnabled(false);
        jtfDescricao.setEnabled(true);
        jtfData.setEnabled(true);
        jtfNrParc.setEnabled(true);
        jtfValor.setEnabled(true);
        jtfObsFin.setEnabled(true);
        jtfDescricao.requestFocus();
        conexao.AutoIncrementa("fin_plano_pagamento");
        jtfCodigo.setText(conexao.AutoIncRS);
        jtfDescricao.setText("");
        jtfData.setText("");
        jtfNrParc.setText("");
        jtfValor.setText("");
        jtfObsFin.setText("");
}//GEN-LAST:event_btNovoActionPerformed

    private void btAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlterarActionPerformed
        btSalvar.setEnabled(true);
        btRemover.setEnabled(true);
        btNovo.setEnabled(false);
        jtfDescricao.setEnabled(true);
        jtfData.setEnabled(true);
        jtfNrParc.setEnabled(true);
        jtfValor.setEnabled(true);
        jtfObsFin.setEnabled(true);
}//GEN-LAST:event_btAlterarActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        novo = true;
        btSalvar.setEnabled(false);
        btAlterar.setEnabled(false);
        btRemover.setEnabled(false);
        btNovo.setEnabled(true);
        jtfDescricao.setEnabled(false);
        jtfData.setEnabled(false);
        jtfNrParc.setEnabled(false);
        jtfValor.setEnabled(false);
        jtfObsFin.setEnabled(false);
        jtfCodigo.setText("");
        jtfDescricao.setText("");
        jtfData.setText("");
        jtfNrParc.setText("");
        jtfValor.setText("");
        jtfObsFin.setText("");
        conexao.RemoveAutoIncrementa("fin_plano_pagamento");
    }//GEN-LAST:event_btCancelarActionPerformed

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        Date data;
        String dtbanco;
        try {
            data = new SimpleDateFormat("dd/MM/yyyy").parse(jtfData.getText());
            dtbanco = new SimpleDateFormat("yyyy-MM-dd").format(data);
            conexao.stm.executeUpdate("update fin_plano_pagamento set descricao=\""+jtfDescricao.getText()+"\", dt_inicio=\""+dtbanco+"\", nr_parcela="+jtfNrParc.getText()+", valor="+jtfValor.getText()+", juro_mes="+jtfJrMes.getText()+", juro_dia="+jtfJrDia.getText()+", desconto="+jtfDesconto.getText()+", obs_fin=\""+jtfDesconto.getText()+"\" where codigo="+jtfCodigo.getText()+" and cod_emp="+index.cod_emp+"");
            conexao.AutoIncRS="";
            CarregaTabela();
            jtfCodigo.setText("");
            jtfDescricao.setText("");
            jtfData.setText("");
            jtfNrParc.setText("");
            jtfValor.setText("");
            jtfObsFin.setText("");
            jtfDescricao.setEnabled(false);
            jtfData.setEnabled(true);
            jtfNrParc.setEnabled(true);
            jtfValor.setEnabled(true);
            jtfObsFin.setEnabled(true);
            btSalvar.setEnabled(false);
            btRemover.setEnabled(false);
            btNovo.setEnabled(true);
            novo = true;
        } catch (SQLException ex) {
            Logger.getLogger(cadBancoVer.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParseException ex) {
            Logger.getLogger(cadPlanoPagVer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btSalvarActionPerformed

    private void btRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRemoverActionPerformed
        try {
            conexao.stm.executeUpdate("delete from fin_plano_pagamento where codigo="+jtfCodigo.getText()+" and cod_emp="+index.cod_emp+"");
            CarregaTabela();
            jtfCodigo.setText("");
            jtfDescricao.setText("");
            jtfData.setText("");
            jtfNrParc.setText("");
            jtfValor.setText("");
            jtfObsFin.setText("");
            jtfDescricao.setEnabled(false);
            jtfData.setEnabled(true);
            jtfNrParc.setEnabled(true);
            jtfValor.setEnabled(true);
            jtfObsFin.setEnabled(true);
            btSalvar.setEnabled(false);
            btRemover.setEnabled(false);
            btAlterar.setEnabled(false);
            btNovo.setEnabled(true);
            novo = true;
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
}//GEN-LAST:event_btRemoverActionPerformed

    private void btSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairActionPerformed
        btCancelarActionPerformed(evt);
        cadPlanoPagVer.this.setVisible(false);
        cadPlanoPagVer.this.dispose();
}//GEN-LAST:event_btSairActionPerformed

    private void jtBancoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtBancoMouseClicked
        if(novo){
            if(evt.getClickCount()==2){
                btSalvar.setEnabled(true);
                btRemover.setEnabled(true);
                jtfDescricao.setEnabled(true);
                jtfData.setEnabled(true);
                jtfNrParc.setEnabled(true);
                jtfValor.setEnabled(true);
                jtfObsFin.setEnabled(true);
                btNovo.setEnabled(false);
            }else{
                jtfCodigo.setText(""+jtBanco.getValueAt(jtBanco.getSelectedRow(), 0));
                jtfDescricao.setText(""+jtBanco.getValueAt(jtBanco.getSelectedRow(), 1));
                jtfData.setText(""+jtBanco.getValueAt(jtBanco.getSelectedRow(), 3));
                jtfNrParc.setText(""+jtBanco.getValueAt(jtBanco.getSelectedRow(), 2));
                jtfValor.setText(""+jtBanco.getValueAt(jtBanco.getSelectedRow(), 4));
                btAlterar.setEnabled(true);
            }
        }
}//GEN-LAST:event_jtBancoMouseClicked

    private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated
            CarregaTabela();        
    }//GEN-LAST:event_formInternalFrameActivated

    private void CarregaTabela(){
        try {
            Date data;
            String dtbanco;
            javax.swing.table.DefaultTableModel jtb = (javax.swing.table.DefaultTableModel)jtBanco.getModel();
            for(int x=(jtBanco.getRowCount()-1);x>=0; --x ){
                jtb.removeRow(x);
            }
            conexao.Query("SELECT codigo,descricao,nr_parcela,dt_inicio,valor FROM fin_plano_pagamento where cod_emp="+index.cod_emp+" order by descricao");
            while(conexao.rs.next()){
                data = (conexao.rs.getString("dt_inicio")!=null) ? new SimpleDateFormat("yyyy-MM-dd").parse(conexao.rs.getString("dt_inicio")):null;
                dtbanco = (data!=null)?new SimpleDateFormat("dd/MM/yyyy").format(data):null;
                jtb.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao"),conexao.rs.getString("nr_parcela"),dtbanco,conexao.rs.getString("valor")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        } catch (ParseException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barraFerramentaFonecedor;
    private javax.swing.JButton btAlterar;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btNovo;
    private javax.swing.JButton btRemover;
    private javax.swing.JButton btSair;
    private javax.swing.JButton btSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JPanel jpCBPrincipal;
    private javax.swing.JPanel jpCadastro;
    private javax.swing.JPanel jpTabela;
    private javax.swing.JTable jtBanco;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JFormattedTextField jtfData;
    private javax.swing.JTextField jtfDesconto;
    private javax.swing.JTextField jtfDescricao;
    private javax.swing.JTextField jtfJrDia;
    private javax.swing.JTextField jtfJrMes;
    private javax.swing.JTextField jtfNrParc;
    private javax.swing.JEditorPane jtfObsBoleto;
    private javax.swing.JTextArea jtfObsFin;
    private javax.swing.JFormattedTextField jtfValor;
    // End of variables declaration//GEN-END:variables

}
